import pygame

s_init = 40
s_final = 25

class Ball:
	
	def __init__(self, screen, distance):
		self.__it = 0
		self.__distance = distance
		self.__x = screen.get_width()/2 - 10
		self.__y = screen.get_height() - 40		
		self.__z = 0
		self.__original = pygame.image.load('ball.gif')
		self.__dx = 0
		self.__dy = 0

	
	def draw(self, screen):
		self.__resize()
		self.translate()
		screen.blit(self.__image, (self.__x, self.__y))
		
	def translate(self):
		self.__y += self.__dy
		self.__x += self.__dx
			
	def set_destiny(self, destiny):
		self.__dx = (destiny[0] - self.__x)/self.__distance
		self.__dy = (destiny[1] - self.__y)/self.__distance
	
	def __resize(self):
		size = (s_init*(self.__distance - self.__it) + s_final*self.__it)/self.__distance
		self.__image = pygame.transform.scale(self.__original, (size, size))
		self.__it = self.__it + 1
